(function(){
    var e = YAHOO, d = e.util.Dom, c = e.util.Event, a = e.lang, b = e.env.ua, f = e.util.Connect;
    TB.namespace("Fastbuy");
    TB.FastBuy = function(){
        var i = "", h = "", j = "";
        var g = null, k = null;
        return {
            init: function(l){
                i = l
            },
            setParams: function(l, m){
                h = l;
                j = !!m
            },
            hidePopup: function(){
                d.setStyle("J_LoginPopup", "display", "none")
            },
            showFastBuyBtn: function(){
                d.setStyle("J_FastBuyBtn", "visibility", "visible")
            },
            hideFastBuyBtn: function(){
                d.setStyle("J_FastBuyBtn", "visibility", "hidden")
            },
            go: function(){
                var l = ["cart_id=" + h, j ? "from=cart_cod" : "from=cart_buynow", "use_cod=" + j];
                location.href = i + (i.indexOf("?") > 0 ? "&" : "?") + l.join("&")
            }
        }
    }();
    TB.namespace("TC");
    TB.TC.Cart = (function(){
        var h = "http://" + document.domain + "/auction/";
        var i = {
            save: h + "cart/update_cart_quantity.htm",
            del: h + "cart/delete_cart_items.htm",
            batchDel: h + "cart/batch_del_cart_items.htm",
            go: h + "order/confirm_order.htm",
            fastbuy: "http://buy.taobao.com/fastbuy/fast_buy.htm",
            login: "",
            loginIndicator: ""
        };
        var g = {};
        var j = false;
        var q = {
            del: function(){
                var t = "cart_id=" + this.getAttribute("data-cartid");
                var s = this;
                f.asyncRequest("POST", i.del + "?_input_charset=utf-8&t=" + new Date().getTime(), {
                    success: function(u){
                        var v = a.trim(u.responseText);
                        if (v === "ok") {
                            p(s)
                        }
                        else {
                            alert(v)
                        }
                    },
                    timeout: 3000
                }, t)
            },
            delSelected: function(){
                var u = [], s = [];
                d.getElementsBy(function(v){
                    return v.type === "checkbox" && v.id !== "J_SelectAll" && v.checked
                }, "input", "J_CartEnable", function(v){
                    u.push(v.value);
                    s.push(v.parentNode.parentNode)
                });
                if (u.length === 0) {
                    alert("\u8bf7\u9009\u62e9\u5b9d\u8d1d");
                    return
                }
                if (confirm("\u786e\u5b9a\u8981\u5220\u9664 \u9009\u4e2d \u7684\u5b9d\u8d1d\u5417\uff1f")) {
                    var t = "cart_ids=" + u.join("&cart_ids=");
                    f.asyncRequest("POST", i.batchDel + "?_input_charset=utf-8&t=" + new Date().getTime(), {
                        success: function(v){
                            var w = a.trim(v.responseText);
                            if (w === "ok") {
                                d.batch(s, p)
                            }
                            else {
                                alert(w)
                            }
                        },
                        timeout: 3000
                    }, t)
                }
            },
            selectAll: function(){
                var s = this;
                e.lang.later(0, null, function(){
                    d.getElementsBy(function(t){
                        return t.type === "checkbox" && t.id !== "J_SelectAll" && !t.disabled
                    }, "input", "J_CartEnable", function(t){
                        t.checked = s.checked;
                        d[t.checked ? "addClass" : "removeClass"](t.parentNode.parentNode, "selected")
                    });
                    m()
                })
            },
            go: function(t){
                if (d.get("cart").getAttribute("data-error")) {
                    alert(d.get("cart").getAttribute("data-error"));
                    return
                }
                var x = [], v = [], y = [];
                d.getElementsBy(function(z){
                    return z.type === "checkbox" && z.id !== "J_SelectAll" && z.checked
                }, "input", "J_CartEnable", function(z){
                    x.push(z.value);
                    var A = d.getAncestorByTagName(z, "TR");
                    y.push(A.getAttribute("data-itemid"));
                    if (!d.hasClass(A, "uncod")) {
                        v.push(z.value)
                    }
                });
                if (x.length === 0) {
                    alert("\u8bf7\u9009\u62e9\u5b9d\u8d1d");
                    return
                }
                m();
                var w = i.go + (i.go.indexOf("?") >= 0 ? "&" : "?") + "cart_id=" + x.join(",") + (t ? t : "");
                var u = (t || "").indexOf("use_cod=true") >= 0;
                var s = u ? v.join(",") : x.join(",");
                TB.FastBuy.setParams(s, u);
                TB.TC.LoginPopup.checkLogin(w, s, u, y.join(";"), x);
                return
            },
            codGo: function(){
                if (typeof e.widget.Panel === "undefined") {
                    e.lang.later(100, q, arguments.callee);
                    return
                }
                var s = uncodNum = 0;
                d.getElementsByClassName("selected", "tr", "J_CartEnable", function(v){
                    s++;
                    d.hasClass(v, "uncod") && (uncodNum++)
                });
                switch (true) {
                    case s === 0:
                        alert("\u8bf7\u9009\u62e9\u5546\u54c1");
                        break;
                    case s === uncodNum:
                        alert("\u60a8\u9009\u62e9\u7684\u5546\u54c1\u4e0d\u652f\u6301\u8d27\u5230\u4ed8\u6b3e\u65b9\u5f0f\u4ea4\u6613");
                        break;
                    case uncodNum === 0:
                        l();
                        break;
                    default:
                        d.setStyle("J_CodPopup_c", "z-index", "10");
                        d.setStyle("J_CodPopup_c", "visibility", "visible");
                        d.get("J_UnCodNum").innerHTML = uncodNum;
                        d.get("J_CartEnableCopy") && d.get("J_CartEnableCopy").parentNode.removeChild(d.get("J_CartEnableCopy"));
                        var t = d.get("J_CartEnable").cloneNode(true);
                        t.id = "J_CartEnableCopy";
                        d.get("J_CodPopupBody").appendChild(t);
                        var u = d.get("J_CartEnableCopy").getElementsByTagName("col");
                        u[0].parentNode.removeChild(u[0]);
                        u[6].parentNode.removeChild(u[6]);
                        d.getElementsByClassName("shop", "tr", "J_CartEnableCopy", function(v){
                            v.getElementsByTagName("td")[0].setAttribute("colspan", "6")
                        });
                        d.getElementsBy(function(v){
                            return !d.hasClass(v, "shop") && v.parentNode.nodeName === "TBODY"
                        }, "tr", "J_CartEnableCopy", function(w){
                            if (d.hasClass(w, "selected") && d.hasClass(w, "uncod")) {
                                var v = d.getElementsByClassName("text-amount", "input", w)[0];
                                v.parentNode.innerHTML = v.value
                            }
                            else {
                                var x = (w.parentNode.getElementsByTagName("tr").length <= 2) ? w.parentNode : w;
                                x.parentNode.removeChild(x)
                            }
                        });
                        if (typeof TB.ww !== "undefined") {
                            d.getElementsByClassName("J_WangWang", "span", "J_CartEnableCopy", function(v){
                                v.innerHTML = ""
                            });
                            TB.ww.lightAll("J_CartEnableCopy")
                        }
                        break
                }
            },
            xCard: function(){
                if (!d.getElementsByClassName("xcard", "tr", "J_CartEnable").length) {
                    return
                }
                var s = 0, t = 0, u = d.get("J_xCardTip");
                d.getElementsByClassName("selected", "tr", "J_CartEnable", function(v){
                    s++;
                    d.hasClass(v, "xcard") && (t++)
                });
                if ((t > 0) && (s !== t)) {
                    u.style.display = "block"
                }
                else {
                    if (("block" === u.style.display) && ((s === t) || (t == 0))) {
                        u.style.display = "none"
                    }
                }
            }
        };
        var m = function(){
            var s = point = 0;
            d.getElementsBy(function(t){
                return t.type === "checkbox" && t.checked
            }, "input", "J_CartEnable", function(t){
                var u = t.parentNode.parentNode;
                d.getElementsByClassName("s-total", "td", u, function(v){
                    s += v.firstChild.firstChild.nodeValue * 1
                });
                d.getElementsByClassName("s-point", "td", u, function(v){
                    point += v.firstChild.firstChild.nodeValue * 1
                })
            });
            d.get("J_Total") && (d.get("J_Total").firstChild.nodeValue = s.toFixed(2));
            d.get("J_Point") && (d.get("J_Point").firstChild.nodeValue = point)
        };
        var o = function(){
            var s = true;
            d.getElementsBy(function(t){
                return t.type === "checkbox" && t.id !== "J_SelectAll"
            }, "input", "J_CartEnable", function(t){
                d[t.checked ? "addClass" : "removeClass"](t.parentNode.parentNode, "selected");
                if (!t.disabled && !t.checked) {
                    s = false
                }
            });
            d.get("J_SelectAll") && (d.get("J_SelectAll").checked = s);
            m()
        };
        var p = function(t){
            t.setAttribute("data-animating", "true");
            var u = d.getElementsBy(function(v){
                return !v.getAttribute("data-animating")
            }, "tr", t.parentNode).length === 1 ? t.parentNode : t;
            var s = new YAHOO.util.Anim(u, {
                opacity: {
                    to: 0
                }
            }, b.ie ? 0.1 : 0.5, YAHOO.util.Easing.easeOut);
            s.onComplete.subscribe(function(){
                u.parentNode.removeChild(u);
                if (d.get("cart").getElementsByTagName("tbody").length === 0) {
                    d.addClass("cart", "hidden");
                    d.removeClass("empty", "hidden")
                }
                else {
                    if (document.getElementById("J_CartDisable") && document.getElementById("J_CartDisable").getElementsByTagName("tbody").length === 0) {
                        d.addClass("J_CartDisable", "hidden")
                    }
                    else {
                        m()
                    }
                }
                var w = d.get("J_CodGo");
                if (w) {
                    var x = [];
                    var y = [];
                    var v = d.get("J_CartEnable").getElementsByTagName("tbody");
                    d.batch(v, function(z){
                        d.batch(z.getElementsByTagName("tr"), function(A){
                            if (!d.hasClass(A, "shop")) {
                                y.push(A)
                            }
                        })
                    });
                    d.batch(y, function(z){
                        if (d.hasClass(z, "uncod")) {
                            x.push(z)
                        }
                    });
                    if (x.length == y.length) {
                        d.addClass(w, "hidden")
                    }
                }
            });
            s.animate()
        };
        var n = function(){
            var y = a.trim(this.value) * 1;
            var s = this.getAttribute("data-max") * 1, t = this.getAttribute("data-now") * 1;
            switch (true) {
                case s === 0:
                    r.call(this, "\u5e93\u5b58\u4e0d\u8db3");
                    return;case t > s:
                    this.setAttribute("data-now", s);
                    if (y <= 0 || y > s) {
                        var w = d.hasClass(this.parentNode.parentNode, "J_LimitPromotion") ? "\u6700\u591a\u53ea\u53ef\u8d2d\u4e70" + s + "\u4ef6" : "\u6700\u5927\u5e93\u5b58\u4e3a" + s;
                        w = "\u6700\u5927\u5e93\u5b58\u4e3a" + s;
                        r.call(this, w);
                        return
                    }
            }
            switch (true) {
                case !/^\d+$/.test(y + ""):
                    r.call(this, "\u8bf7\u586b\u5199\u6b63\u786e\u7684\u5b9d\u8d1d\u6570\u91cf");
                    return;case y <= 0:
                    r.call(this, "\u5b9d\u8d1d\u6570\u91cf\u5fc5\u987b\u662f\u5927\u4e8e0");
                    return;case y > s:
                    r.call(this, "\u6700\u591a\u53ea\u53ef\u8d2d\u4e70" + s + "\u4ef6");
                    return
            }
            k.call(this);
            var z = this.parentNode.parentNode;
            var u = this;
            var x = z.getAttribute("data-cartid");
            var v = "cart_id=" + x + "&quantity=" + this.value;
            f.asyncRequest("POST", i.save + (i.save.indexOf("?") >= 0 ? "&" : "?") + "_input_charset=utf-8&t=" + new Date().getTime(), {
                success: function(A){
                    try {
                        var B = a.JSON.parse(A.responseText);
                        d.getElementsBy(function(E){
                            return true
                        }, "td", z, function(E){
                            if (d.hasClass(E, "s-point")) {
                                E.firstChild.firstChild.nodeValue = B.obtainPoint
                            }
                            else {
                                if (d.hasClass(E, "s-total")) {
                                    E.firstChild.firstChild.nodeValue = B.amount
                                }
                            }
                        });
                        m();
                        u.setAttribute("data-now", u.value)
                    } 
                    catch (C) {
                        var D = A.responseText;
                        if (typeof D == "string" && a.trim(D) !== "") {
                            alert(a.trim(D));
                            u.value = u.getAttribute("data-now")
                        }
                    }
                },
                timeout: 3000
            }, v)
        };
        var r = function(u){
            k.call(this);
            var s = document.createElement("em");
            s.appendChild(document.createTextNode(u));
            this.parentNode.appendChild(s);
            this.value = this.getAttribute("data-now");
            var t = this.parentNode.parentNode.getAttribute("data-cartid");
            !g[t] && (g[t] = {
                error: null,
                key: null
            });
            g[t].error && g[t].error.cancel();
            g[t].error = YAHOO.lang.later(2000, this, function(){
                k.call(this)
            })
        };
        var k = function(){
            var s = this.parentNode.getElementsByTagName("em")[0];
            s && s.parentNode.removeChild(s)
        };
        var l = function(){
            q.go("&use_cod=true")
        };
        return {
            init: function(s){
                if (s) {
                    a.augmentObject(i, s, true)
                }
                c.onDOMReady(function(){
                    o();
                    q.xCard();
                    TB.TC.LoginPopup.init(i.login, i.loginIndicator);
                    TB.FastBuy.init(i.fastbuy);
                    c.on("cart", "click", function(z){
                        var y = c.getTarget(z);
                        switch (true) {
                            case d.hasClass(y.parentNode, "s-del"):
                                c.stopEvent(z);
                                if (confirm("\u786e\u5b9a\u8981\u5220\u9664\u8be5\u5b9d\u8d1d\u5417\uff1f")) {
                                    q.del.call(y.parentNode.parentNode)
                                }
                                break;
                            case d.hasClass(y, "minus"):
                                c.stopEvent(z);
                                var w = d.getNextSibling(y);
                                w.value = w.value * 1 - 1;
                                n.call(w);
                                break;
                            case d.hasClass(y, "plus"):
                                c.stopEvent(z);
                                var w = d.getPreviousSibling(y);
                                w.value = w.value * 1 + 1;
                                n.call(w);
                                break;
                            case y.id === "J_PointTipTrigger":
                                c.stopEvent(z);
                                var x = d.getNextSibling("J_PointTipTrigger");
                                d[d.hasClass(x, "hidden") ? "removeClass" : "addClass"](x, "hidden");
                                break;
                            case y.id === "J_PointTipClose":
                                c.stopEvent(z);
                                var x = y.parentNode;
                                d.addClass(x, "hidden");
                                break;
                            case y.id === "J_Go":
                                if (j) {
                                    alert("\u5bf9\u4e0d\u8d77\uff0c\u4e00\u4e9b\u9650\u65f6\u6253\u6298\u6d3b\u52a8\u5df2\u7ecf\u5230\u671f");
                                    location.reload();
                                    break
                                }
                                if (d.get("J_CodGo") && d.hasClass(d.get("J_CodGo"), "clickThis")) {
                                    d.removeClass(d.get("J_CodGo"), "clickThis")
                                }
                                q.go();
                                break;
                            case y.id === "J_CodGo":
                                if (j) {
                                    alert("\u5bf9\u4e0d\u8d77\uff0c\u4e00\u4e9b\u9650\u65f6\u6253\u6298\u6d3b\u52a8\u5df2\u7ecf\u5230\u671f");
                                    location.reload();
                                    break
                                }
                                if (!d.hasClass(y, "clickThis")) {
                                    d.addClass(y, "clickThis")
                                }
                                q.codGo();
                                break;
                            case y.id === "J_DelSelect":
                                q.delSelected();
                                break;
                            case y.type === "checkbox":
                                if (y.id === "J_SelectAll") {
                                    q.selectAll.call(y)
                                }
                                else {
                                    o()
                                }
                                e.lang.later(0, null, function(){
                                    q.xCard()
                                });
                                break
                        }
                    });
                    d.getElementsByClassName("text-amount", "input", "J_CartEnable", function(y){
                        var w = document.createElement("a");
                        w.className = "minus";
                        w.appendChild(document.createTextNode("-"));
                        d.insertBefore(w, y);
                        var x = document.createElement("a");
                        x.className = "plus";
                        x.appendChild(document.createTextNode("+"));
                        d.insertAfter(x, y);
                        w.href = x.href = "#";
                        c.on(y, "keydown", function(){
                            e.lang.later(0, this, function(){
                                var A = this.parentNode.parentNode.getAttribute("data-cartid");
                                var z = a.trim(this.value) === "" ? 1500 : 300;
                                !g[A] && (g[A] = {
                                    error: null,
                                    key: null
                                });
                                g[A].key && g[A].key.cancel();
                                g[A].key = YAHOO.lang.later(z, this, function(){
                                    n.call(this)
                                })
                            })
                        })
                    });
                    var t = 100000000;
                    d.getElementsByClassName("J_LimitPromotion", "tr", "J_CartEnable", function(x){
                        var w = x.getAttribute("data-timeleft");
                        if (w && (w * 1 < t)) {
                            t = w * 1
                        }
                    });
                    a.later(t * 1000, null, function(){
                        j = true
                    });
                    var u = document.createElement("div");
                    u.className = "discount-pop hidden";
                    u.innerHTML = "<ul><li></li></ul><span></span>";
                    document.body.appendChild(u);
                    d.getElementsByClassName("J_Aigo", "img", "J_CartEnable", function(w){
                        if (w.getAttribute("data-popstr")) {
                            TB.widget.SimplePopup.decorate(w, u, {
                                eventType: "mouse",
                                offset: [-25, 13],
                                autoFit: false,
                                onShow: function(){
                                    u.getElementsByTagName("li")[0].innerHTML = this.trigger.getAttribute("data-popstr")
                                }
                            })
                        }
                    });
                    if (b.ie === 6) {
                        d.getElementsBy(function(w){
                            return w.parentNode.nodeName === "TBODY" && !d.hasClass(w, "shop")
                        }, "tr", "J_CartEnable", function(w){
                            c.on(w, "mouseenter", function(){
                                d.addClass(this, "hover")
                            });
                            c.on(w, "mouseleave", function(){
                                d.removeClass(this, "hover")
                            })
                        })
                    }
                    if (b.ie) {
                        d.getElementsByClassName("gift", "div", "cart", function(w){
                            c.on(w, "mouseenter", function(){
                                d.addClass(this, "gift-hover")
                            });
                            c.on(w, "mouseleave", function(){
                                d.removeClass(this, "gift-hover")
                            })
                        })
                    }
                    if (typeof TB.ww === "undefined") {
                        e.util.Get.script("http://a.tbcdn.cn/sys/wangwang/tbww_v1.2.js?auto=false&t=20090512", {
                            onSuccess: function(){
                                if (typeof TB.ww !== "undefined") {
                                    TB.ww.lightAll(document.body)
                                }
                            },
                            timeout: 10000,
                            autopurge: false,
                            charset: document.charset || document.characterSet || "gb2312"
                        })
                    }
                    if (d.get("J_CodGo") && typeof e.widget.Panel === "undefined") {
                        var v = document.createElement("div");
                        v.id = "J_CodPopup";
                        v.className = "cod-popup";
                        document.body.appendChild(v);
                        e.util.Get.script(TB.env.yuipath + "build/container/container-min.js", {
                            onSuccess: function(){
                                if (typeof e.widget.Panel === "undefined") {
                                    return
                                }
                                var y = document.createElement("div");
                                y.id = "J_CodPopupBody";
                                y.className = "msg24";
                                y.innerHTML = '<p class="attention">															\u4f60\u6709<span id="J_UnCodNum"></span>\u4e2a\u5b9d\u8d1d\u4e0d\u652f\u6301\u8d27\u5230\u4ed8\u6b3e\u7ed3\u7b97\u65b9\u5f0f<br />															<span class="skin-blue"><button class="small-btn" type="button" id="J_CodBtn">\u786e\u5b9a</button></span>															<a href="#" id="J_CodBack" class="cartback">\u8fd4\u56de\u8d2d\u7269\u8f66</a>														</p>';
                                var w = new e.widget.Panel("J_CodPopup", {
                                    width: "872px",
                                    visible: false,
                                    draggable: false
                                });
                                w.setBody(y);
                                w.render("container");
                                c.on("J_CodBtn", "click", l);
                                c.on("J_CodBack", "click", function(z){
                                    c.stopEvent(z);
                                    d.setStyle("J_CodPopup_c", "visibility", "hidden")
                                });
                                var x = document.createElement("div");
                                x.id = "J_Overlay";
                                x.className = "underlay";
                                x.style.height = d.getDocumentHeight() + "px";
                                d.get("J_CodPopup_c").appendChild(x)
                            },
                            timeout: 10000,
                            autopurge: false,
                            charset: document.charset || document.characterSet || "gb2312"
                        });
                        TB.dom.addCSS("										.cod-popup th.s-point a, .cod-popup th.s-point em { display:none !important; }										.cod-popup .s-chk, .cod-popup .s-del { display:none; }										.cod-popup tfoot { display:none; }										.cod-popup .attention { margin-bottom:12px; }										")
                    }
                })
            },
            go: function(){
                if (d.get("J_CodGo") && d.hasClass(d.get("J_CodGo"), "clickThis")) {
                    q.go("&use_cod=true")
                }
                else {
                    q.go()
                }
            }
        }
    })();
    TB.TC.AtPanel = function(){
        return {
            doTrack: function(i, h){
                var g = document.createElement("IMG");
                g.src = "http://www.atpanel.com/1.gif?cache=" + (new Date().getTime()) + "&category=" + i + "&itemid=" + h
            }
        }
    }();
    TB.TC.LoginPopup = function(){
        var i = null, n = "", t = "", k = "", m = false;
        var j = YAHOO.util, o = YAHOO.lang, s = j.Dom, q = j.Event, r = document;
        var l = 460, p = 320;
        var g = function(){
            s.setStyle(i, "top", s.getDocumentScrollTop() + (s.getViewportHeight() - p) / 2 + "px");
            s.setStyle(i, "left", (s.getViewportWidth() - l) / 2 + "px")
        };
        var h = function(z){
            z = z || n;
            var u = z.indexOf("showfastbuy=true") > 0;
            l = u ? 640 : 460;
            i = document.createElement("div");
            i.id = "J_LoginPopup";
            i.className = "login-now";
            s.setStyle(i, "z-index", "9999");
            i.style.width = (l + 2) + "px";
            i.style.height = (p + 2) + "px";
            var v = document.createElement("div");
            v.className = "skin";
            var w = document.createElement("iframe");
            w.setAttribute("width", "" + l);
            w.setAttribute("height", "" + p);
            w.setAttribute("src", z);
            w.setAttribute("frameborder", "0", 0);
            w.setAttribute("scrolling", "no");
            v.appendChild(w);
            var B = document.createElement("div");
            B.innerHTML = "<a href='#' style='background:transparent url(http://img01.taobaocdn.com/tps/i1/T1EedkXbY_yJNsaZzT-300-812.png) no-repeat scroll -245px -32px; display:block; height:17px; position:absolute; right:6px; top:6px; width:17px;' title='\u5173\u95ed'><span style='display:none'>\u5173\u95ed</span></a>";
            B = B.firstChild;
            v.appendChild(B);
            q.on(B, "click", function(E){
                q.stopEvent(E);
                TB.FastBuy.hidePopup()
            });
            var A = document.createElement("div");
            A.innerHTML = "<a id='J_FastBuyBtn' href='#' title='\u5feb\u901f\u8d2d\u4e70' style='background:white url(http://img01.taobaocdn.com/tps/i1/T1MedkXXj_yJQ5vBcy-220-240.png) no-repeat scroll -97px -151px; height:30px; width:123px; text-align:center; line-height:30px; color:white; font-size:14px; font-weight:bold; position:absolute; top:102px; left:36px; visibility:hidden;'>\u5feb\u901f\u8d2d\u4e70</a>";
            A = A.firstChild;
            v.appendChild(A);
            q.on(A, "click", function(E){
                q.stopEvent(E);
                TB.FastBuy.go()
            });
            i.appendChild(v);
            document.body.appendChild(i);
            var D = function(G){
                var F = G.split(".");
                var E = F.length;
                if (E < 2) {
                    return G
                }
                return F[E - 2] + "." + F[E - 1]
            };
            document.domain = D(location.hostname);
            var x = o.later(0, this, function(){
            });
            q.on(window, "scroll", function(){
                if ("block" === i.style.display) {
                    x.cancel();
                    x = o.later(500, this, g)
                }
            });
            var y = o.later(0, this, function(){
            });
            q.on(window, "resize", function(){
                if ("block" === i.style.display) {
                    y.cancel();
                    y = o.later(500, this, g)
                }
            });
            var C = true;
            h = function(F){
                F = F || n || "";
                var E = F.indexOf("showfastbuy=true") > 0;
                s.setStyle(A, "display", E ? "block" : "none");
                TB.FastBuy[E ? "showFastBuyBtn" : "hideFastBuyBtn"]();
                var G = w.getAttribute("src") + "";
                if (G.substr(0, G.lastIndexOf("t=") - 1) !== F) {
                    l = E ? 640 : 460;
                    i.style.width = (l + 2) + "px";
                    i.style.height = (p + 2) + "px";
                    w.setAttribute("width", "" + l);
                    w.setAttribute("height", "" + p);
                    w.setAttribute("src", "about:blank");
                    w.setAttribute("src", F)
                }
                else {
                    if (!C) {
                        w.setAttribute("src", F + (F.indexOf("?") ? "&" : "?") + "t=" + (new Date().getTime()))
                    }
                    C = false
                }
                g();
                i.style.display = "block"
            };
            return h(z)
        };
        return {
            init: function(v, u){
                n = v;
                apiLoginIndicator = u
            },
            checkLogin: function(A, v, w, u, y){
                k = A;
                var z = TB.TC.LoginPopup.checkByCookie;
                if (apiLoginIndicator) {
                    var x = apiLoginIndicator + (apiLoginIndicator.indexOf("?") > 0 ? "&" : "?") + "cart_ids=" + v + "&var=login_indicator&t=" + new Date().getTime();
                    if (("" + w).indexOf("use_cod=true")) {
                        x += "&use_cod=true"
                    }
                    YAHOO.util.Get.script(x, {
                        onSuccess: function(){
                            var C = window.login_indicator;
                            if ((C.success && C.hasLoggedIn) || !C.success) {
                                z()
                            }
                            else {
                                if (!C.hasLoggedIn) {
                                    var D = "", B = s.get("J_Go");
                                    TB.TC.AtPanel.doTrack(C.hasPhantomLoggedIn ? "cartbuy_user" : "cartbuy_viewer", u);
                                    D = C.popupWindow.replace("&showfastbuy=true", "");
                                    D = YAHOO.lang.trim(D);
                                    if (s.getAttribute(B, "data-addFastBuy")) {
                                        if (C.isFastBuy && y.length === 1) {
                                            TB.FastBuy.go()
                                        }
                                        else {
                                            if (C.popupWindow) {
                                                TB.TC.LoginPopup.show(D)
                                            }
                                            else {
                                                z()
                                            }
                                        }
                                    }
                                    else {
                                        if (!C.hasPhantomLoggedIn) {
                                            if (y.length > 1) {
                                                TB.TC.LoginPopup.show(D)
                                            }
                                            else {
                                                TB.FastBuy.go()
                                            }
                                        }
                                        else {
                                            TB.TC.LoginPopup.show(D)
                                        }
                                    }
                                }
                            }
                        },
                        onFailure: z,
                        onTimeout: z,
                        timeout: 5000
                    })
                }
                else {
                    z()
                }
            },
            checkByCookie: function(){
                window.location.href = k
            },
            show: function(u){
                h(u)
            }
        }
    }();
    TB.TC.CartRelatedItems = function(){
        var h = YAHOO.util, n = YAHOO.lang, q = h.Dom, p = h.Event;
        var r = document, j = r.body;
        var g = null, i = $("J_RecentlyViewed"), o = $("J_OthersBought"), l = (+new Date).toString();
        var m = function(){
            var u = ((-1 === g.historyUrl.indexOf("?")) ? "?" : "&") + "callback=TB.TC.CartRelatedItems.showRecentlyViewed&t=" + l;
            h.Get.script(g.historyUrl + u, {
                timeout: 10000,
                autopurge: false,
                charset: r.charset || r.characterSet || "gb2312"
            })
        };
        var k = function(y){
            var u = r.createElement("ul");
            u.className = "clearfix";
            var w = [];
            for (var v = y.length - 1; 0 <= v; v--) {
                var x = y[v];
                x.link = "http://ju.atpanel.com/?url=" + x.link + "?ad_id=&am_id=&cm_id=&pm_id=1500121087bd5308a47e";
                w.unshift('<li>							<div class="item">								<div class="pic s60">									<a hidefocus="true" href="' + x.link + '" target="_blank" title="' + x.title + '"><img alt="' + x.title + '" src="' + x.picURL.replace(/_sum/g, "_60x60") + '" /></a>								</div>								<div class="price">									<strong>' + x.price + "</strong>								</div>							</div>						</li>")
            }
            u.innerHTML = w.join("");
            i.parentNode.replaceChild(u, i);
            i = null
        };
        var t = function(){
            var u = ((-1 === g.promoteUrl.indexOf("?")) ? "?" : "&") + "callback=TB.TC.CartRelatedItems.showOthersBought&t=" + l;
            h.Get.script(g.promoteUrl + u, {
                timeout: 10000,
                autopurge: false,
                charset: r.charset || r.characterSet || "gb2312"
            })
        };
        var s = function(y){
            var u = r.createElement("ul");
            u.className = "clearfix";
            var w = [];
            for (var v = y.length - 1; 0 <= v; v--) {
                var x = y[v];
                x.link = "http://ju.atpanel.com/?url=" + x.link + "?ad_id=&am_id=&cm_id=&pm_id=150012108882a30a058e";
                w.unshift('<li>							<div class="item">								<div class="pic s80">									<a hidefocus="true" href="' + x.link + '" target="_blank" title="' + x.title + '"><img alt="' + x.title + '" src="' + x.picURL.replace(/_70x70/g, "_80x80") + '" /></a>								</div>								<div class="desc">									<a href="' + x.link + '" target="_blank" title="' + x.title + '">' + x.title + '</a>								</div>								<div class="price">									<strong>' + x.price + "</strong>								</div>							</div>						</li>")
            }
            u.innerHTML = w.join("");
            o.parentNode.replaceChild(u, o);
            o = null
        };
        return {
            init: function(u){
                if (undefined === u || Object !== u.constructor) {
                    return false
                }
                else {
                    g = u;
                    u = null
                }
                if (null !== i && undefined !== g.historyUrl && "" !== g.historyUrl) {
                    m()
                }
                if (null !== o && undefined !== g.promoteUrl && "" !== g.promoteUrl) {
                    t()
                }
            },
            showRecentlyViewed: function(u){
                if (undefined === u || Object !== u.constructor || undefined === u.items || Array !== u.items.constructor || 0 === u.items.length) {
                    return false
                }
                k(u.items)
            },
            showOthersBought: function(u){
                if (undefined === u || Object !== u.constructor || undefined === u.items || Array !== u.items.constructor || 0 === u.items.length) {
                    return false
                }
                s(u.items)
            }
        }
    }()
})();
(function(){
    TB.namespace("CartToFav");
    var d = YAHOO.util, a = d.Dom, n = d.Event, j = YAHOO.lang, b = YAHOO.env.ua, e = d.Cookie, k = d.Connect, f = d.Get;
    var c = {
        FAVORITE_API: "",
        BROWSE_API: "http://auction1.taobao.com/auction/json/latest_visit.htm?at_iframe=&tname=json/searchBrowsedAuction.vm&channel=&domain=",
        LIKE_API: "http://favorite.taobao.com/json/promote_banner.htm?count=5&pages=1",
        BUY_API: "",
        REMOVE_API: ""
    };
    var m = function(p, o){
        o = (typeof o === "undefined") ? "block" : o;
        a.setStyle(p, "display", o)
    };
    var l = function(o){
        a.setStyle(o, "display", "none")
    };
    var g = function(p, t){
        var q, r = (p.indexOf("?") === -1) ? "?" : "&", o = [], s = "";
        for (q in t) {
            o[o.length] = "&" + q + "=" + encodeURIComponent(t[q])
        }
        s = o.join("").substring(1);
        return p + r + s
    };
    var i = function(){
        var p = 0.3, o = a.get("J_UnableCauction");
        var r = function(){
            var s = "expand-box", t = o.clientHeight;
            var u = new d.Anim(o, {
                height: {
                    to: o.scrollHeight
                }
            }, p);
            u.onComplete.subscribe(function(){
                var w = this.attributes.height, v = Math.max(o.scrollHeight, o.clientHeight);
                w.to = (w.to === t) ? v : t;
                if (a.hasClass(o, s)) {
                    a.removeClass(o, s)
                }
                else {
                    a.addClass(o, s)
                }
            });
            return function(){
                u.animate()
            }
        };
        var q = function(u){
            var s, y, v = c.REMOVE_API, x = a.get("J_LostCartIds").value, w = a.getAncestorBy(u, function(z){
                return z.tagName.toLowerCase() === "tbody"
            });
            var t = function(){
                if (!a.get("J_PopRemove")) {
                    var z = a.getXY(u);
                    s = document.createElement("div");
                    s.id = "J_PopRemove";
                    s.className = "msg";
                    s.innerHTML = '<p class="attention">\u7cfb\u7edf\u7e41\u5fd9, \u9ebb\u70e6\u60a8\u7a0d\u540e\u518d\u8bd5\u54e6</p>';
                    o.appendChild(s);
                    a.setStyle(s, "top", z[1] + "px");
                    a.setStyle(s, "left", (z[0] + u.offsetWidth + 10) + "px")
                }
                m(s)
            };
            return function(){
                var z = "cart_ids=" + x.split(",").join("&cart_ids=");
                k.asyncRequest("POST", v, {
                    success: function(B){
                        var A = new d.Anim(o, {
                            height: {
                                to: o.clientHeight - w.clientHeight
                            }
                        }, p);
                        A.onComplete.subscribe(function(){
                            w.parentNode.removeChild(w)
                        });
                        A.animate()
                    },
                    failure: function(A){
                        if (y) {
                            clearTimeout(y)
                        }
                        t();
                        y = setTimeout(function(){
                            l(s)
                        }, 2000)
                    }
                }, z)
            }
        };
        return {
            init: function(){
                if (!o) {
                    return
                }
                var t = a.get("J_Toggle"), s = a.get("J_BtnRemove");
                n.on(t, "click", r());
                if (a.get("J_LostCartIds")) {
                    n.on(s, "click", q(s))
                }
            }
        }
    };
    var h = function(){
        var u = a.get("J_Auctions");
        if (!u) {
            return {
                init: function(){
                }
            }
        }
        var z = a.getChildren(a.getFirstChild(u)), x = a.getElementsByClassName("pannel", "div", u), F = "success", p = "failure", I = "timeout", r = "favorite", D = "browse", B = "buy", G = "like", J = '<p class="tip-loading tip"><img src="http://pics.taobaocdn.com/bao/album/sys/loading_32x32.gif" />\u6570\u636e\u52a0\u8f7d\u4e2d...</p>', t = '<p class="tip-nodata tip">\u6682\u65e0\u6700\u8fd1\u6d4f\u89c8\u8fc7\u7684\u5b9d\u8d1d</p>', q = "http://ju.atpanel.com/?url=", s = "?ad_id=&am_id=&cm_id=&pm_id=", C = s + "15001250084ca92e6beb", v = s + "1500121087bd5308a47e", w = s + "150012108882a30a058e";
        var o = function(K, L){
            K.innerHTML = L
        };
        var A = function(){
            var M = a.getFirstChild(u).getElementsByTagName("li"), N = a.getElementsByClassName("pannel", "div", u), Q = false, L = 2000, R;
            var K = TB.widget.SimpleTab.decorate(u, {
                eventType: "mouse",
                currentClass: "current",
                onSwitch: function(S){
                    var T = z.indexOf(M[S]);
                    switch (T) {
                        case 1:
                            y(D, 1);
                            break;
                        case 2:
                            y(G, 2);
                            break
                    }
                }
            });
            var O = function(){
                var T = 0, S = M.length;
                (function(){
                    if (Q) {
                        if (R) {
                            clearTimeout(R)
                        }
                        return
                    }
                    T = T % S + 1;
                    T = (T >= S) ? 0 : T;
                    K.switchTab(T);
                    R = setTimeout(arguments.callee, L)
                })()
            };
            var P = function(){
                if (R) {
                    clearTimeout(R)
                }
                Q = true
            };
            R = setTimeout(O, L);
            if (b.ie) {
                n.on(u, "mouseenter", P)
            }
            else {
                n.on(u, "mouseover", function(T){
                    var S = n.getRelatedTarget(T);
                    if (S !== u && !a.isAncestor(u, S)) {
                        P()
                    }
                })
            }
        };
        var y = function(){
            var K = function(P, N){
                var Q = g(c.FAVORITE_API, {
                    t: +new Date()
                });
                var O = function(){
                    var R = z[N];
                    R.parentNode.removeChild(R);
                    P.parentNode.removeChild(P)
                };
                f.script(Q, {
                    onSuccess: function(R){
                        P.status = F;
                        if (result && result.collectList) {
                            H(P, result.collectList, r);
                            P.innerHTML += "<a class='gotomyfav' href='http://favorite.taobao.com/collect_list.htm?scjjc=d2'>\u53bb\u6211\u7684\u6536\u85cf\u5939 >></a>"
                        }
                        else {
                            O()
                        }
                        A();
                        R.purge()
                    },
                    onFailure: function(R){
                        P.status = p;
                        O();
                        A();
                        R.purge()
                    },
                    onTimeout: function(R){
                        P.status = I;
                        O();
                        A();
                        R.purge()
                    },
                    autopurge: true,
                    charset: "gbk"
                })
            };
            var L = function(N){
                var O = g(c.BROWSE_API, {
                    t: +new Date(),
                    callback: "TB.CartToFav.Interest.getBrowse"
                });
                f.script(O, {
                    onSuccess: function(Q){
                        var P = a.getFirstChild(N);
                        N.status = F;
                        if (P && a.hasClass(P, "tip-loading")) {
                            o(N, t)
                        }
                        Q.purge()
                    },
                    onFailure: function(P){
                        N.status = p;
                        o(N, t);
                        P.purge()
                    },
                    onTimeout: function(P){
                        N.status = I;
                        o(N, t);
                        P.purge()
                    },
                    autopurge: true,
                    charset: "gbk"
                })
            };
            var M = function(O){
                if (result) {
                    result = null
                }
                var N = g(c.BUY_API, {
                    t: +new Date()
                });
                var P = function(Q){
                    var R = g(c.LIKE_API, {
                        t: +new Date(),
                        callback: "TB.CartToFav.Interest.getLike"
                    });
                    f.script(R, {
                        onSuccess: function(S){
                            Q.status = F;
                            S.purge()
                        },
                        onFailure: function(S){
                            Q.status = p;
                            S.purge()
                        },
                        onTimeout: function(S){
                            Q.status = I;
                            S.purge()
                        },
                        autopurge: true,
                        charset: "gbk"
                    })
                };
                f.script(N, {
                    onSuccess: function(Q){
                        if (result && result.collectList && result.collectList.length) {
                            O.status = F;
                            H(O, result.collectList, B)
                        }
                        else {
                            P(O)
                        }
                        Q.purge()
                    },
                    onFailure: function(Q){
                        P(O);
                        Q.purge()
                    },
                    onTimeout: function(Q){
                        P(O);
                        Q.purge()
                    },
                    autopurge: true,
                    timeout: 1500,
                    charset: "gbk"
                })
            };
            return function(P, N){
                var O = x[N];
                if (O.status === F) {
                    return
                }
                o(O, J);
                switch (P) {
                    case r:
                        K(O, N);
                        break;
                    case D:
                        L(O);
                        break;
                    case G:
                        M(O);
                        break
                }
            }
        }();
        var H = function(){
            var N = /_sum\.jpg|_70x70\.jpg/, L = "_160x160.jpg";
            var K = function(P){
                var O = [];
                Array.forEach(P, function(R, Q){
                    if (Q < 5) {
                        O[O.length] = {
                            title: R.title,
                            price: R.price,
                            detailUrl: R.link,
                            imageUrl: R.picURL
                        }
                    }
                });
                return O
            };
            var M = function(R, Q){
                var O = [], P;
                switch (Q) {
                    case r:
                        P = C;
                        break;
                    case D:
                        P = v;
                        break;
                    case B:
                    case G:
                        P = w;
                        break
                }
                O[O.length] = "<ul>";
                Array.forEach(R, function(T){
                    var S = q + T.detailUrl + P;
                    O[O.length] = '<li><a href="' + S + '" target="_blank" class="pic">';
                    O[O.length] = '<img src="' + T.imageUrl.replace(N, L) + '" /></a>';
                    O[O.length] = '<a href="' + S + '" target="_blank" class="desc">' + T.title + "</a>";
                    O[O.length] = '<span class="price">' + T.price + "</span></li>"
                });
                return O.join("") + "</ul>"
            };
            return function(Q, P, O){
                if (j.isUndefined(P) || j.isUndefined(Q)) {
                    return
                }
                if (O && (O === D || O === G)) {
                    P = K(P)
                }
                Q.innerHTML = M(P, O)
            }
        }();
        var E = function(P, K, M, O){
            var L = x[K], N = P.items;
            if (N && N.length) {
                H(L, N, M)
            }
            else {
                if (O) {
                    o(L, O)
                }
            }
        };
        return {
            init: function(){
                y(r, 0)
            },
            getBrowse: function(K){
                E(K, 1, D, t)
            },
            getLike: function(K){
                E(K, 2, G)
            }
        }
    };
    TB.CartToFav.init = function(o){
        if (!j.isObject(o)) {
            return
        }
        j.augmentObject(c, o, true);
        TB.CartToFav.Unable = i();
        TB.CartToFav.Interest = h();
        TB.CartToFav.Unable.init();
        TB.CartToFav.Interest.init()
    }
})();
